package procilege.impl.formatter;

import javax.xml.namespace.QName;

import procilege.compute.ExprFormatTraveller;
import procilege.compute.PlaceType;
import procilege.compute.TravelMap;

public class ExprFormatTravellerImpl implements ExprFormatTraveller {

	private StringBuilder builder;

	private TravelMap<ExprFormatTraveller> travelmap;
	
	private long  localNameSn = 1;

	public ExprFormatTravellerImpl(StringBuilder sb,
			TravelMap<ExprFormatTraveller> travelmap) {

		this.builder = sb;
		this.travelmap = travelmap;
	}

	public StringBuilder getBuilder() {
		return builder;
	}

	public String assignNamePrefix(QName qn) {
		return null;
	}

	public Object setout(Object place) {

		if (place == null)
			return null;

		PlaceType<ExprFormatTraveller> op = travelmap.find(place.getClass());
		if (op == null)
			return place;

		op.visit(this, place);

		return null;
	}

	public long newLocalNameSn() {
		
		return localNameSn ++;
	}
}
